@extends('admin.frame_layout')
<?php $top_selected = "会员管理";$page_menu = "升级指定会员" ?>
@section('content')
    <div class="formbody">
        <div class="formtitle"><span>升级指定会员</span></div>
        <form action="{{route('admin.vipup.save')}}" method="post" id="form">
            {!! csrf_field() !!}
            <ul class="forminfo">
                {!! inputText("会员账号", "username", "text", "", "请输入会员账号！") !!}

                {{--{!! inputSelect("选择等级","vip",[--}}
                    {{--["value"=>1,"title"=>"普通会员","selected"=>true],--}}
                    {{--["value"=>2,"title"=>"银级会员"],--}}
                    {{--["value"=>3,"title"=>"金级会员"]--}}
                {{--],"请选择要升级的等级！") !!}--}}
                <li>
                    <label class="lable">选择等级</label>
                    <select name="vip" id="vip">
                        <option value="0">请选择晋升等级</option>
                        @foreach($vips as $vip)
                            <option value="{{$vip->slug}}">{{$vip->name}}</option>
                        @endforeach
                    </select>
                    <i for="vip_id">请选择要升级的等级</i>
                </li>
                <li>
                    <label class="lable">&nbsp;</label>
                    <input type="submit" class="btn" value="确认升级"/>
                </li>
            </ul>
        </form>
    </div>
@endsection
@section('footer')
    <script>
        $("#form").validate({
            rules: {
                username: "required",
                vip: "required"
            }, errorPlacement: function (error, element) {
                $(element).closest("form").find("i[for='" + element.attr("id") + "']").html(error);
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    success: function (data) {
                        if (data.code == 0) {
                            toastr["success"](data.msg);
                            setInterval(function () {
                                window.location.reload();
                            }, 2000);
                        } else {
                            toastr["error"](data.msg);
                        }
                    }
                });
            }
        });
    </script>
@endsection
